--
-- DESCRIPTION
--
-- @COMPANY **
-- @AUTHOR **
-- @DATE ${date} ${time}
--

---@type AIC_Runner_C
local M = UnLua.Class()

-- function M:Initialize(Initializer)
-- end

-- function M:UserConstructionScript()
-- end

function M:ReceiveBeginPlay()
    self:SimulateInputWithDelay()
end

-- function M:ReceiveEndPlay()
-- end

-- function M:ReceiveTick(DeltaSeconds)
-- end

-- function M:ReceiveAnyDamage(Damage, DamageType, InstigatedBy, DamageCauser)
-- end

-- function M:ReceiveActorBeginOverlap(OtherActor)
-- end

-- function M:ReceiveActorEndOverlap(OtherActor)
-- end

-- 模拟输入等待延迟
function M:SimulateInputWithDelay()
    UE.UKismetSystemLibrary.K2_SetTimerDelegate(
            { self, self.SimulateInput },
            UE.UKismetMathLibrary.RandomFloatInRange(self.MinInputDelay, self.MaxInputDelay),
            false)
end

function M:ReceivePossess(PossessedPawn)
    local BP_RunnerClass = UE.UClass.Load("/Script/Engine.Blueprint'/MashRunner/Blueprints/BP_Runner.BP_Runner_C'")
    self.OwningRunner = PossessedPawn:Cast(BP_RunnerClass)
end

-- 模拟输入
function M:SimulateInput()

    if self.OwningRunner == nil then
        return
    end

    if self.ChangeOfFeet == false then
        self.ChangeOfFeet = true
        self.OwningRunner:SimulatePowerLeft()
    else
        self.ChangeOfFeet = false
        self.OwningRunner:SimulatePowerRight()
    end

    self:SimulateInputWithDelay()
end

return M
